package cn.mjnxin.iot.connector.coder;

import java.util.List;

import cn.mjnxin.iot.base.domain.ChannelData;
import cn.mjnxin.iot.connector.context.IPeerContext;
import cn.mjnxin.iot.transfer.TransferExchange.IUnpacker;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

/**
 * 解码器，将字节形式的报文解码成ChannelData对象
 * 
 * 如果当前拦截器没有向out中写入数据则后续的handler也不会被执行了

 * @author CLG 2023年10月10日
 * @version V1.0.0
 */
public class Gate2GateDecoder  extends ByteToMessageDecoder implements IUnpacker{
	private final boolean isAllMatch;
	private final Integer pid;
	// 日志等级 0：无日志 1：报文长度日志 2：报文内容日志 3：所有日志
	private final Integer logLevel;
    private final IPeerContext context;
    
    public Gate2GateDecoder(boolean isAllMatch, Integer pid, Integer logLevel, IPeerContext context) {
    	this.isAllMatch = isAllMatch;
    	this.pid = pid;
    	this.logLevel = logLevel;
        this.context = context;
    }

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    	//GateHostExchange.decode(ctx, in, out, this);
    }

    public ChannelData unpackOnePackage(Channel channel, ChannelData originData, int type, boolean isIPV4) {
    	return null;
    }

	public boolean isAllMatch() {
		return isAllMatch;
	}

	public Integer getPid() {
		return pid;
	}

	public IPeerContext getContext() {
		return context;
	}
}
